Hello,
Module m = current
Object o
for o in selectedObjects m do {
...
}
SystemAdmin - Mon Mar 07 10:27:36 EST 2011 |
Re: loop on selected objects
If you want to confine the loop to only the objects that have been selected in a contiguous order - that is - the user has selected the start of a selection and then used SHIFT click to select the end of a selection (DOORS changes the color of the selected range to red text) then the following will work - to prove that it works I've added an incrementing counter and print statement that confirms that the loop only works on the contiguously selected objects.
Module m = current
Object o, startObj, endObj
int x = 0
getSelection(m,startObj, endObj)
if (!null startObj) { //if range has been selected, otherwise do nothing
while (!null startObj && isSelected startObj) {
x++
print identifier(startObj) "\n"
startObj = next(startObj)
}
print "Total Obj in selection=" x""
}
else
{
print "No selection made"
}
Module m = current
Object o
for o in m do {.....}
Paul Miller |
Re: loop on selected objects Miller's method may work, but I'm pretty set in my ways and have done it like this:
Skip fGetSelectedObjects(Module in_mod)
{ // Return a Skip List of objects that are currently selected in the module.
// 'Selected' means either a range of objects or the currently selected single object.
// Return an empty skip list when there are no selected objects
// Calling program should delete the Skip when finished.
Skip skpObjects = create() // Return KEY and DATA both 'Object'
if (null in_mod) return(skpObjects)
Object oCurr = current,
o
for o in entire (in_mod) do
{ if (isSelected(o) or
o == oCurr) put(skpObjects, o, o)
}
return(skpObjects)
} // end fGetSelectedObjects()
Skip skpObjects = fGetSelectedObjects(current Module)
Object o
for o in skpObjects do
{ // deal with the selected o
print (identifier(o)) "\tIsSeletected\n"
}
delete(skpObjects)
|
Re: loop on selected objects llandale - Tue Mar 08 16:32:32 EST 2011 Miller's method may work, but I'm pretty set in my ways and have done it like this:
Skip fGetSelectedObjects(Module in_mod)
{ // Return a Skip List of objects that are currently selected in the module.
// 'Selected' means either a range of objects or the currently selected single object.
// Return an empty skip list when there are no selected objects
// Calling program should delete the Skip when finished.
Skip skpObjects = create() // Return KEY and DATA both 'Object'
if (null in_mod) return(skpObjects)
Object oCurr = current,
o
for o in entire (in_mod) do
{ if (isSelected(o) or
o == oCurr) put(skpObjects, o, o)
}
return(skpObjects)
} // end fGetSelectedObjects()
Skip skpObjects = fGetSelectedObjects(current Module)
Object o
for o in skpObjects do
{ // deal with the selected o
print (identifier(o)) "\tIsSeletected\n"
}
delete(skpObjects)
Paul Miller Melbourne, Australia |
Re: loop on selected objects SystemAdmin - Tue Mar 08 17:50:06 EST 2011 Paul Miller Melbourne, Australia Now that I think of it, however, I see that may main program will process the objects in "Object" order; not sure what to think about that. I should change the function to keep a "counter" and put the "Counter++" as the skip list "Key", they would thus be retrieved by the main in the natural order; I think the same order that your algorithm correctly finds them.
These are more like two-pair and trips; good hands easily trumped by better hands. |
Re: loop on selected objects llandale - Wed Mar 09 15:00:36 EST 2011
These are more like two-pair and trips; good hands easily trumped by better hands. Vincent. |
Re: loop on selected objects SystemAdmin - Thu Mar 10 12:07:11 EST 2011 Gents,
The approach "appears" to be flawless, but it doesn't take into account the state of the filter.I am trying to determine the best way forward, but am a bit stumped! Here is what I have:
void StandardizeAircraftType(string ThisOrThat)
{
Skip fGetSelectedObjects(Module in_mod)
{
Skip skpObjects = create()
if (null in_mod)
{
return(skpObjects)
}
Object oCurr = current, o
for o in entire (in_mod) do
{
if (isSelected(o) or o == oCurr)
{
put(skpObjects, o, o)
}
}
return(skpObjects)
}
Skip skpObjects = fGetSelectedObjects(current Module)
Object o
for o in skpObjects do
{ // deal with the selected o
print (identifier(o)) "\tIsSeletected\n"
o."Thing" = ThisOrThat
}
delete(skpObjects)
}
StandardizeAircraftType("This")
Say I have an attribute ("Thing"), and I have three possible values, "None, This, or That". Now, say, I have half of my objects set to "None", and about a 1/3 set to "This". If I select the "None" objects, with a corresponding string of "ZZ" in the object text (via a filter), highlight all, and run the script to change all the "None" to "That", I have this problem where it doesn't recognize the filter being on and some items being "out of view". Therefore, all items, filter or no filter, between the selection start and selection end are being updated. How do I further limit the issue to only see Selectable and Filtered data before editing??
Thanks again!
PS...is it just me or are there a bunch of cross symbols ( ) showing up every time I place a double space somewhere?? |
Re: loop on selected objects [SOLVED]
Nevermind, I just solved my own question: I should be using "isFiltered".
void StandardizeAircraftType(string ThisOrThat)
{
Skip fGetSelectedObjects(Module in_mod)
{
Skip skpObjects = create()
if (null in_mod)
{
return(skpObjects)
}
Object oCurr = current, o
for o in entire (in_mod) do
{
if ((isSelected(o) && isFiltered(o)) or o == oCurr)
{
put(skpObjects, o, o)
}
}
return(skpObjects)
}
Skip skpObjects = fGetSelectedObjects(current Module)
Object o
for o in skpObjects do
{ // deal with the selected o
print (identifier(o)) "\tIsSeletected\n"
o."Thing" = ThisOrThat
}
delete(skpObjects)
}
StandardizeAircraftType("This")
|